Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new security-questions module #295

Merged
merged 16 commits into from
Jul 23, 2024

Conversation

Adamkadaban
Copy link
Contributor

@Adamkadaban Adamkadaban commented May 8, 2024

Description

this module will dump security questions and answers for all users on the machine assuming run as administrator

requires this PR to work: fortra/impacket#1743


Reference: https://hackback.zip/2024/05/08/Remotely-Dumping-Windows-Security-Questions-With-Impacket.html

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

Only tested against windows 10 and windows 11.
Ran e2e tests

Screenshots

image
example output shows <Username> - <Question>: <Answer> for each user

Checklist

  • I have ran Ruff against my changes (via poetry: poetry run python -m ruff check . --preview, use --fix to automatically fix what it can)
  • I have added or updated the tests/e2e_commands.txt file if necessary
  • New and existing e2e tests pass locally with my changes
  • My code follows the style guidelines of this project (should be covered by Ruff above)
  • If reliant on third party dependencies, such as Impacket, dploot, lsassy, etc, I have linked the relevant PRs in those projects
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (PR here: add docs for security-questions module NetExec-Wiki#11)

@Marshall-Hallenbeck
Copy link
Collaborator

@Adamkadaban did you run Ruff against this? If you are using poetry: poetry run python -m ruff check . --preview

@Adamkadaban
Copy link
Contributor Author

did you run Ruff against this?

@Marshall-Hallenbeck Oh sorry, I didn't - but I have now. made the necessary changes and all checks are passing

@Dfte
Copy link
Contributor

Dfte commented May 12, 2024

Quick question but since these informations are dumped calling the SAMR RPC endpoint, can't we simply add this module in the code --sam option ?

@Adamkadaban
Copy link
Contributor Author

Adamkadaban commented May 12, 2024

@Dfte I considered this too. I would say yes, but afaik --sam currently only tries to dump passwords in the sam database.
There are a ton of things we can dump with samr that currently aren't being dumped, so I assumed the best option would be a module

Adamkadaban added a commit to Adamkadaban/NetExec-Wiki that referenced this pull request May 12, 2024
Copy link
Contributor

@NeffIsBack NeffIsBack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what is happening here, but when i swap out the print() for the exception logging this is the traceback:
image

nxc/modules/security-questions.py Outdated Show resolved Hide resolved
@Adamkadaban
Copy link
Contributor Author

@NeffIsBack

Not sure what is happening here, but when i swap out the print() for the exception logging this is the traceback:

This looks like the very verbose logging that impacket provides when an information class doesn't exist.

I think this means your impacket is outdated

@NeffIsBack
Copy link
Contributor

@NeffIsBack

Not sure what is happening here, but when i swap out the print() for the exception logging this is the traceback:

This looks like the very verbose logging that impacket provides when an information class doesn't exist.

I think this means your impacket is outdated

Oh yes, it's late, missed the fortra PR notice. Gonna update impacket and try again👍🏼

@NeffIsBack
Copy link
Contributor

Hmm okay so with impacket being updated i get an error on the dc and no output at all on the win11 machine. There should be a local account set up with sec questions.
image
image

The DC debug output:
image

The Win11 debug output (looks like its running fine, but doesn't find anything?):
image

@Marshall-Hallenbeck Marshall-Hallenbeck force-pushed the dumpSecurityQuestionsModule branch from f8b7a02 to 39b877a Compare June 18, 2024 15:06
Copy link
Collaborator

@Marshall-Hallenbeck Marshall-Hallenbeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, just requesting some variable renames so it's Python3-Pythonic.

nxc/modules/security-questions.py Outdated Show resolved Hide resolved
nxc/modules/security-questions.py Outdated Show resolved Hide resolved
nxc/modules/security-questions.py Outdated Show resolved Hide resolved
nxc/modules/security-questions.py Outdated Show resolved Hide resolved
nxc/modules/security-questions.py Outdated Show resolved Hide resolved
nxc/modules/security-questions.py Outdated Show resolved Hide resolved
NeffIsBack
NeffIsBack previously approved these changes Jul 18, 2024
Copy link
Contributor

@NeffIsBack NeffIsBack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM:
image

Fyi, changed the loop from break to continue as we would otherwise stop if the first user doesn't have security questions.

@NeffIsBack
Copy link
Contributor

Looks like on DC this object doesn't have the UserResetInformation block. I added a try&Except block (with debug logging) just in case other servers have the same problem with some users.
image

@Marshall-Hallenbeck Marshall-Hallenbeck self-requested a review July 19, 2024 00:57
@NeffIsBack NeffIsBack merged commit cb639c8 into Pennyw0rth:main Jul 23, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants